/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * HDRResponseFunctionCalculatorFrame.java
 *
 * Created on 27.11.2008, 08:37:45
 */
package hdr_plugin;

import hdr_plugin.response.ResponseFunctionCalculator;
import hdr_plugin.response.ResponseFunctionCalculatorSettings;
import hdr_plugin.helper.ArrayTools;

/**
 *
 * @author Alex
 */
public class HDRResponseFunctionCalculatorFrame extends java.awt.Frame {
    private ResponseFunctionCalculator calculator;
    /** Creates new form HDRResponseFunctionCalculatorFrame */
    public HDRResponseFunctionCalculatorFrame(ResponseFunctionCalculator calculator) {
        initComponents();
        this.calculator = calculator;
        this.txtNoOfPixels.setText(String.valueOf(calculator.getResponseFunctionCalculatorSettings().getNoOfPixelsN()));
        this.txtNoOfChannels.setText(String.valueOf(calculator.getResponseFunctionCalculatorSettings().getNoOfChannels()));
        this.txtNoOfImages.setText(String.valueOf(calculator.getResponseFunctionCalculatorSettings().getNoOfImagesP()));
        this.txtExpTimes.setText(ArrayTools.arrayToString(calculator.getResponseFunctionCalculatorSettings().getExpTimes()));
        this.lblAlgorithm_.setText(calculator.getAlgorithm());
        this.chcChannel.insert("all", 0);
        for (int i = 1; i <= calculator.getResponseFunctionCalculatorSettings().getNoOfChannels(); i++) {
            chcChannel.add(String.valueOf(i));
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        lblLogo = new javax.swing.JLabel();
        pnlContent = new java.awt.Panel();
        txtNoOfPixels = new java.awt.TextField();
        txtNoOfImages = new java.awt.TextField();
        txtNoOfChannels = new java.awt.TextField();
        chcChannel = new java.awt.Choice();
        lblNoOfPixels = new java.awt.Label();
        lblNoOfImages = new java.awt.Label();
        lblNoOfChannels = new java.awt.Label();
        lblChannels = new java.awt.Label();
        txtExpTimes = new java.awt.TextField();
        lblExpTimes = new java.awt.Label();
        lblAlgorithm = new java.awt.Label();
        lblAlgorithm_ = new java.awt.Label();
        pnlButtons = new java.awt.Panel();
        btnCalc = new java.awt.Button();
        btnSave = new java.awt.Button();
        btnCancel = new java.awt.Button();
        btnHelp = new java.awt.Button();

        setBackground(new java.awt.Color(255, 255, 255));
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });
        setLayout(new java.awt.GridBagLayout());

        lblLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/hdr_plugin/resources/log.jpg"))); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0);
        add(lblLogo, gridBagConstraints);

        pnlContent.setLayout(new java.awt.GridBagLayout());

        txtNoOfPixels.setEditable(false);
        txtNoOfPixels.setEnabled(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.ipadx = 50;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        pnlContent.add(txtNoOfPixels, gridBagConstraints);

        txtNoOfImages.setEditable(false);
        txtNoOfImages.setEnabled(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.ipadx = 50;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        pnlContent.add(txtNoOfImages, gridBagConstraints);

        txtNoOfChannels.setEditable(false);
        txtNoOfChannels.setEnabled(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.ipadx = 50;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        pnlContent.add(txtNoOfChannels, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        pnlContent.add(chcChannel, gridBagConstraints);

        lblNoOfPixels.setText("Number of Pixels (N):");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        pnlContent.add(lblNoOfPixels, gridBagConstraints);

        lblNoOfImages.setText("Number of Images (P):");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        pnlContent.add(lblNoOfImages, gridBagConstraints);

        lblNoOfChannels.setText("Number of Channels:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        pnlContent.add(lblNoOfChannels, gridBagConstraints);

        lblChannels.setText("Select Channel:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        pnlContent.add(lblChannels, gridBagConstraints);

        txtExpTimes.setEditable(false);
        txtExpTimes.setEnabled(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.ipadx = 200;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        pnlContent.add(txtExpTimes, gridBagConstraints);

        lblExpTimes.setText("List of Exposure Times");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        pnlContent.add(lblExpTimes, gridBagConstraints);

        lblAlgorithm.setText("Algorithm:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
        pnlContent.add(lblAlgorithm, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        pnlContent.add(lblAlgorithm_, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5);
        add(pnlContent, gridBagConstraints);

        pnlButtons.setLayout(new java.awt.GridBagLayout());

        btnCalc.setLabel("Calculate");
        btnCalc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCalcActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        pnlButtons.add(btnCalc, gridBagConstraints);

        btnSave.setEnabled(false);
        btnSave.setLabel("Save");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        pnlButtons.add(btnSave, gridBagConstraints);

        btnCancel.setLabel("Cancel");
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        pnlButtons.add(btnCancel, gridBagConstraints);

        btnHelp.setFont(new java.awt.Font("Lucida Grande", 1, 13));
        btnHelp.setLabel("Help");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
        pnlButtons.add(btnHelp, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        add(pnlButtons, gridBagConstraints);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
        this.dispose();
    }//GEN-LAST:event_exitForm

    private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnCancelActionPerformed

    private void btnCalcActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCalcActionPerformed
       double out[] = calculator.calcResponse(0);
    }//GEN-LAST:event_btnCalcActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private java.awt.Button btnCalc;
    private java.awt.Button btnCancel;
    private java.awt.Button btnHelp;
    private java.awt.Button btnSave;
    private java.awt.Choice chcChannel;
    private java.awt.Label lblAlgorithm;
    private java.awt.Label lblAlgorithm_;
    private java.awt.Label lblChannels;
    private java.awt.Label lblExpTimes;
    private javax.swing.JLabel lblLogo;
    private java.awt.Label lblNoOfChannels;
    private java.awt.Label lblNoOfImages;
    private java.awt.Label lblNoOfPixels;
    private java.awt.Panel pnlButtons;
    private java.awt.Panel pnlContent;
    private java.awt.TextField txtExpTimes;
    private java.awt.TextField txtNoOfChannels;
    private java.awt.TextField txtNoOfImages;
    private java.awt.TextField txtNoOfPixels;
    // End of variables declaration//GEN-END:variables
}
